/**
 * Copyright 2011 Joe Choi, All rights reserved.
 */
package tao.calendar.gregorian;

/**
 * 
 * @author Joe Choi
 * @version 1.0.0
 */
class ConcreteModifiableDate extends ConcreteGregorianDate implements ModifiableDate {
	public ConcreteModifiableDate(GregorianDate date) {
		super(date);
	}

	@Override
	public ModifiableDate setEra(Era era) {
		setInternalEra(era);
		return(this);
	}
	
	@Override
	public ModifiableDate setYear(int year) {
		if(year <= 0 || year > MAX_YEAR_VALUE) throw new IllegalArgumentException("Invlid year value[1-1 million]: " + year);
		setInternalYear(year);
		return(this);
	}
	
	@Override
	public ModifiableDate setMonth(int month) {
		if(month < 1 || month > 12) 
			throw new IllegalArgumentException("Invlid month value[1-12]: " + month);
		setInternalMonth(month);
		return(this);
	}
	
	@Override
	public ModifiableDate setDay(int day) {
		if(! isValidDayOfMonth(getYear(), getMonth(), day)) 
			throw new IllegalArgumentException("Invalid day value[1-31]: " + day);
		setInternalDay(day);
		return(this);
	}
}